package com.tedu.user.controller;

import com.tedu.common.response.JsonResult;
import com.tedu.user.pojo.dto.UserFeedbackParam;
import com.tedu.user.pojo.dto.UserFeedbackQuery;
import com.tedu.user.pojo.vo.UserFeedbackVO;
import com.tedu.user.service.UserFeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/userFeedback")
public class UserFeedbackController {
    @Autowired
    private UserFeedbackService userFeedbackService;

    @PostMapping("/save")
    public JsonResult saveUser(UserFeedbackParam userFeedbackParam){
        log.debug("保存反馈信息,参数:{}",userFeedbackParam);
        userFeedbackService.saveUserFeedback(userFeedbackParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult selectUser(UserFeedbackQuery userFeedbackQuery){
        log.debug("查询用户反馈业务,参数:{}",userFeedbackQuery);
        List<UserFeedbackVO> list = userFeedbackService.selectUserFeedback(userFeedbackQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/delete/{feedbackId}")
    public JsonResult deleteFeedback(@PathVariable Long feedbackId) {
        log.debug("删除用户反馈业务:参数={}", feedbackId);
        userFeedbackService.deleteFeedback(feedbackId);
        return JsonResult.ok();
    }

}
